package org.example.Server.strategy.question;

import org.example.Server.mapper.question.QuestionMapper;
import org.example.Server.model.question.Option;
import org.example.Server.model.question.QUpdate;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 判断题的更新策略类
 */
//@Component
public class YorNQsUpdateStrategy implements QsUpdateStrategy {
    private final QuestionMapper questionMapper;

    public YorNQsUpdateStrategy(QuestionMapper questionMapper) {
        this.questionMapper = questionMapper;
    }

    @Override
    public void qsUpdate(QUpdate qs) {
        // 更新选项
        List<Option> updateOptions = qs.getUpdate_options();
        if (updateOptions != null && !updateOptions.isEmpty()) {
            questionMapper.updateOption(updateOptions);
            questionMapper.updateQSandOption(qs);
        }
    }
}
